"""
发送带参数的请求
    要点： 注意获取关键参数的方法
"""
import requests

# 发送带参数的请求
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36'
}

# 方法一：
url1 = 'https://www.baidu.com/s?wd=python'

response1 = requests.get(url1, headers=headers)

with open('./params_baidu_1.html', 'wb') as f1:
    f1.write(response1.content)

# 方法二：
url2 = 'https://www.baidu.com/s?'

params = {
    'wd': 'python'
}

response2 = requests.get(url2, headers=headers, params=params)

with open('./params_baidu_2.html', 'wb') as f2:
    f2.write(response2.content)



